﻿@model PagedList.IPagedList<Mvc5Ef6WebApiDataFirstNthW.Models.Product>

@using PagedList.Mvc;

@{
    ViewBag.Title = "PrintIndexAsPdfPageList";
    ViewBag.Description = "List of the products";
}

@section styles
    {
    <style type="text/css">
        @@media print {
            footer, #tdNotPrinted, #divNotPrinted, #pNotPrinted {
                display: none;
            }
        }

        @@page {
            margin: 0cm;
        }
    </style>
}

<p id="pNotPrinted">
    @Html.ActionLink("Create New", "Create")
</p>
<div class="table-responsive">
    <table class="table table-striped table-bordered table-hover table-condensed">
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.First().ProductName)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().QuantityPerUnit)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().UnitPrice)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().UnitsInStock)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().UnitsOnOrder)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().ReorderLevel)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().Discontinued)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().Category.CategoryName)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().Supplier.CompanyName)
            </th>
            <th></th>
        </tr>


        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.ProductName)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.QuantityPerUnit)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.UnitPrice)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.UnitsInStock)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.UnitsOnOrder)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.ReorderLevel)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Discontinued)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Category.CategoryName)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Supplier.CompanyName)
                </td>
                <td id="tdNotPrinted">
                    @Html.ActionLink("Edit", "Edit", new { id = item.ProductID }) |
                    @Html.ActionLink("Details", "Details", new { id = item.ProductID }) |
                    @Html.ActionLink("Delete", "Delete", new { id = item.ProductID })
                </td>
            </tr>
        }

    </table>
    <br />
    <div id="divNotPrinted">
        Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount

        @Html.PagedListPager(Model, page => Url.Action("Index", new { page }))
    </div>

</div>